dev.off()
cat("\014")
rm(list=ls())
set.seed(18552)

#install.packages("readstata13")
#install.packages("MASS")
#install.packages("gplots")
#install.packages("colorspace")
#install.packages("ggplot2")
#install.packages("reshape2")
#install.packages("margins")
#install.packages("data.table")

library(foreign)
library(readstata13)
dat19 <- read.dta13(file="YAS2019.dta")
dat20 <- read.dta13(file="YAS 2020.dta")
library(gplots)
library(ggplot2)
library(Hmisc)
library(reshape2)
library(margins)
library(MASS)


################################################
####Self Efficacy Plots without Means Labeled###
################################################

par(mfrow=c(1,2))
plotmeans(efficacy ~ Post, data=dat19, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Efficacy 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(efficacy ~ Post, data=dat20, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Efficacy 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)

#############################################
####Self Efficacy Plots with Means Labeled###
#############################################

par(mfrow=c(1,2))
plotmeans(efficacy ~ Post, data=dat19, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Efficacy 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(efficacy ~ Post, data=dat20, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Efficacy 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)


##########################################################
####Community Consciousness Plots without Means Labeled###
##########################################################
par(mfrow=c(1,2))
plotmeans(communityall ~ Post, data=dat19, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Community Consciousness 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(communityall ~ Post, data=dat20, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Community Consciousness 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)


#######################################################
####Community Consciousness Plots with Means Labeled###
#######################################################

par(mfrow=c(1,2))
plotmeans(communityall ~ Post, data=dat19, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Community Consciousness 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(communityall ~ Post, data=dat20, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(3.5,5), xaxt = "n",main="Community Consciousness 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)

############################################
####Knowledge Plots without Means Labeled###
############################################
par(mfrow=c(3,2))
##Knowledge##
plotmeans(knowledge ~ Post, data=dat19, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n", main="Knowledge 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(knowledge ~ Post, data=dat20, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n",main="Knowledge 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
##Verifiable Knowledge##
plotmeans(knowver ~ Post, data=dat19, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n", main="Verifiable Knowledge 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(knowver ~ Post, data=dat20, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1.1),xaxt = "n",main="Verifiable Knowledge 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
##KnowledgeConfidence##
plotmeans(knowcon ~ Post, data=dat19, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n", main="Knowledge Confidence 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(knowcon ~ Post, data=dat20, mean.labels=FALSE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n",main="Knowledge Confidence 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)

##############################
####Plot with Means Labeled###
##############################

par(mfrow=c(3,2))
##Knowledge##
plotmeans(knowledge ~ Post, data=dat19, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n", main="Knowledge 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(knowledge ~ Post, data=dat20, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n",main="Knowledge 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
##Verifiable Knowledge##
plotmeans(knowver ~ Post, data=dat19, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n", main="Verifiable Knowledge 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(knowver ~ Post, data=dat20, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1.1),xaxt = "n",main="Verifiable Knowledge 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
##Knowledge Confidence##
plotmeans(knowcon ~ Post, data=dat19, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n", main="Knowledge Confidence 2019", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
plotmeans(knowcon ~ Post, data=dat20, mean.labels=TRUE, n.label=FALSE, col="red", connect=FALSE, ylim = c(.5,1), xaxt = "n",main="Knowledge Confidence 2020", xlab="Before and After YAS", ylab="Mean Score")
axis(1, at=1:2, labels = c("Before","After"), tck=0)
